package com.aaa.service.impl;

import com.aaa.dao.L_dataqueryDao;
import com.aaa.entity.project;
import com.aaa.entity.treevo;
import com.aaa.service.L_dataqueryService;
import com.aaa.util.EmpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class L_dataqueryServiceImpl implements L_dataqueryService {
    @Autowired
    private L_dataqueryDao dao;

    private  String panduan;

//右侧树形菜单
    @Override
    public Map getYiji(Map m) {
       List<project> list= dao.getYiji(m);
        List<treevo> treeList = new ArrayList<treevo>();
        for (project p : list) {
            //树数据vo类
            treevo ovo = new treevo();
            ovo.setId(p.getId());
            //项目名称
            ovo.setLabel(p.getName());
            treeList.add(ovo);
            List<Map> listTwo = dao.selectListTwo(p.getId());
            if (listTwo.size()>0) {
                List<treevo> treeListTwo = new ArrayList<treevo>();
                for (Map map : listTwo) {
                    //树数据vo类
                    treevo ovoTwo = new treevo();
                    ovoTwo.setId(Integer.parseInt(map.get("id").toString()));
                    //二级菜单内容名称
                    ovoTwo.setLabel(map.get("content").toString());
                    if (panduan=="SH"){
                        //资料审核右侧内容路径
                        ovoTwo.setUrl(map.get("shurl").toString());
                        System.out.println(ovoTwo.getUrl()+"1");
                    }else if (panduan=="CX"){
                        //资料查询右侧内容路径
                        ovoTwo.setUrl(map.get("ckurl").toString());
                        System.out.println(ovoTwo.getUrl()+"2+++++++");
                    }else{
                        //资料申报右侧内容路径
                        ovoTwo.setUrl(map.get("url").toString());
                        System.out.println(ovoTwo.getUrl()+"33333333");
                    }
                    treeListTwo.add(ovoTwo);
                }
                ovo.setChildren(treeListTwo);
            }
        }
        panduan="";
        List<Map> years=dao.selectYears();
        Map map=new HashMap();
        map.put("treeList", treeList);
        map.put("years", years);
        return map;
    }

    public void  panduan(String aa){
        panduan=aa;
    }



    @Override
    public Map getSBXM(String title) {
        Map map=dao.getSBXM(title);
        System.out.println(title+"   service");
        map.put("DWname", EmpUtil.getMessage().getName());
        map.put("grading",EmpUtil.getMessage().getGrading());
        return  map;
    }
//新增申报
    @Override
    public void insertdata(Map map) {
        dao.insertdata(map);
    }
//获取查询菜单
    @Override
    public List<Map> CX(Map map) {
        return dao.CX(map);
    }
    //获取查询条数
    @Override
    public Integer getCount(Map map) {
        return dao.getCount(map);
    }
    //获取查询详情菜单
    @Override
    public Map cha(Integer id) {
        return dao.cha(id);
    }


    //获取审核菜单
    @Override
    public List<Map> getSH(Map map) {
        return dao.getSH(map);
    }
    //获取该审核条数
    @Override
    public Integer getSHcount(Map map) {
        return dao.getSHcount(map);
    }

    @Override
    public int SHgo(Map map) {
        return dao.SHgo(map);
    }

    @Override
    public int rep(Map map) {
        List<Map> list=dao.rep(map);
        if (list.size()>0){
            return list.size();
        }else {
            return 0;
        }
    }
    //审核驳回的信息
    @Override
    public void SHreturn(Map map) {
            dao.SHreturn(map);
    }

    @Override
    public List<Map> getkscore(Map map) {
        return dao.getkscore(map);
    }

    @Override
    public void upkscore(Map map) {
        dao.upkscore(map);
    }

    @Override
    public void setkscore(Map map) {
        dao.setkscore(map);
    }

}
